package com.ysdwl.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ysdwl.model.Bill;
import com.ysdwl.model.Provider;
import com.ysdwl.service.impl.BillService;
import com.ysdwl.service.impl.ProviderService;

@WebServlet(urlPatterns = "/findBill")
public class FindBillServlet extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		try {
			String billName = req.getParameter("billName");
			int tigong = Integer.parseInt(req.getParameter("tigong"));
			int fukuan = Integer.parseInt(req.getParameter("fukuan"));
			
			Bill bill = new Bill();
			bill.setProductName(billName);
			bill.setProviderId(tigong);
			bill.setIsPayment(fukuan);
			BillService billService = new BillService();
			List<Bill> list = billService.findAll(bill);
			
			req.setAttribute("list", list);
			req.getRequestDispatcher("billList.jsp").forward(req, resp);
			
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
			}
		
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req, resp);
	}
}
